package com.study.student_chuji.demos.controller;

import com.study.student_chuji.demos.Mapper.UserMapper;
import com.study.student_chuji.demos.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Calendar;

@Controller
public class LoginController {
    @Autowired
    UserMapper userMapper;

    @GetMapping("/toLoginPage")
    public String toLoginPage(Model model){
        model.addAttribute("currentYear", Calendar.getInstance().get(Calendar.YEAR));
        return "login";
    }

//    @PostMapping("/login")
//    @ResponseBody
//    public String login(User user){
//        System.out.println(user);
//        User userl = userMapper.checkUsernameAndPassword(user);
//        if(userl == null){
//            return "账号密码错误";
//        }
//        else {
//            return "登录成功";
//        }
//    }
}
